package server

import (
	"hw07/handle"
	"net/http"

	"github.com/codegangsta/negroni"
	"github.com/gorilla/mux"
)

func NewServer() *negroni.Negroni {
	router := mux.NewRouter()
	router.PathPrefix("/static/").Handler(http.StripPrefix("/static/", http.FileServer(http.Dir("d:/goworks/src/hw07/assets/"))))

	router.HandleFunc("/json", handle.JsonHandler)

	router.HandleFunc("/login", handle.LoginHandler)

	router.PathPrefix("/").Handler(http.StripPrefix("/", http.FileServer(http.Dir("d:/goworks/src/hw07/"))))

	n := negroni.Classic()
	n.UseHandler(router)
	return n
}
